package com.hujf.netty.inandoutboundhandler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

/**
 * @author Hujf
 * @title: MyByteToLongDecoder2
 * @date 2021/2/6 0006下午 12:01
 * @description: TODO
 */
public class MyByteToLongDecoder2 extends ReplayingDecoder<Void> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        System.out.println("输入端2 解码被调用");
        //long 8字节
//        if(in.readableBytes()>=8){
//            out.add(in.readLong());
//        }
        //继承ReplayingDecoder 后无需判断 内部可以判断
        out.add(in.readLong());
    }
}
